package com.wudao.ncmplay.util;

import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;

/**
 * @Desc AES 密码解析器工具类
 * @author middle2boy
 * @Date 2021-09-09
 */
public class AesUtils
{
    /**
     * 获取AES解密器
     * @param key 密码
     * @param content 解密内容
     * @return byte[]
     */
    public static byte[] decrypt(byte[] key, byte[] content)
    {
        try {
            // 创建密码器
            Cipher cipher = Cipher.getInstance("AES");
            // 初始化为解密模式的密码器
            cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(key, "AES"));
            return cipher.doFinal(content);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
